<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>KWAI激活</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            display: flex;
            flex-direction: column;
            height: 100vh;
            box-sizing: border-box;
            background-color: #f7f7f7;
        }
        .container {
            display: flex;
            flex-direction: column;
            width: 100%;
            max-width: 600px;
            margin: 0 auto;
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        .row {
            display: flex;
            flex-direction: column;
            margin-bottom: 15px;
        }
        .row label {
            font-weight: bold;
            margin-bottom: 5px;
        }
        .row input[type="text"] {
            flex: 1;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 16px;
        }
        .row button {
            padding: 10px;
            border: none;
            border-radius: 4px;
            background-color: #007bff;
            color: white;
            font-size: 16px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }
        .row button:hover {
            background-color: #0056b3;
        }
        pre {
            margin: 10px 0;
            padding: 10px;
            background-color: #f5f5f5;
            border: 1px solid #ddd;
            border-radius: 4px;
            overflow-x: auto;
            white-space: pre-wrap;
            word-wrap: break-word;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="row">
            <label for="pixelId">Pixel ID:</label>
            <input type="text" id="pixelId" placeholder="Enter pixelId">
        </div>
        <div class="row">
            <label for="clickid">Click ID:</label>
            <input type="text" id="clickid" placeholder="Enter clickid">
        </div>
        <div class="row">
            <label for="access_token">Access Token:</label>
            <input type="text" id="access_token" placeholder="Enter access_token">
        </div>
        <div class="row">
            <button onclick="submitRequest()">激活</button>
        </div>
        <pre id="response-pre"></pre>
    </div>

    <script>
        function submitRequest() {
            const pixelId = document.getElementById('pixelId').value;
            const clickid = document.getElementById('clickid').value;
            const accessToken = document.getElementById('access_token').value;

            const payload = {
                "access_token": accessToken,
                "event_name": "EVENT_BUTTON_CLICK",
                "is_attributed": 1,
                "mmpcode": "PL",
                "pixelSdkVersion": "9.9.9",
                "pixelId": pixelId,
                "clickid": clickid,
                "testFlag": false,
                "trackFlag": true
            };

            const url = 'https://www.adsnebula.com/log/common/api';

            // 显示“提交中...”消息
            document.getElementById('response-pre').textContent = '提交中...';

            fetch(url, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(payload)
            })
            .then(response => response.json())
            .then(data => {
                document.getElementById('response-pre').textContent = JSON.stringify(data, null, 4);
            })
            .catch(error => {
                document.getElementById('response-pre').textContent = 'Error: ' + error;
            });
        }
    </script>
</body>
</html>
